<template>
	<page-meta :page-style="'overflow:'+(isscollhidden?'hidden':'visible')">
		<scroll-view :scroll-y="containerScroll" class="goods-scroll" :enhanced="true" :bounces="false"
			:show-scrollbar="false" @scroll="onContainerScroll" scroll-with-animation :scroll-top="scrollToTop">
			<view>
				<view class="head relative">
					<view class="head-cont"
						:style="[{'height': 32 + 'px', 'padding-top': demoinfo.top + 'px','padding-right': demoinfo.width+15 + 'px'}]">
						<view class="center z-[2]" @click="navback"
							:style="[{'height': 32 + 'px','padding-left':10 + 'px'}]">
							<uv-icon name="arrow-left" color="#fff" size="20"></uv-icon>
						</view>
						<view class="z-[2] flex">
							<view class="center weixin mr-[20rpx]" style="background-color: #D8D8D8;"
								@click="gettoserch">
								<image src="../static/homeimg/search.svg" mode="aspectFit" class="w-[24rpx] h-[24rpx]">
								</image>
							</view>
							<button open-type="share" plain class="center  weixin"
								style="background-color: #D8D8D8;border: 1px solid #BEBEBE;">
								<view @click="onShareAppMessage" open-type="share">
									<uv-icon name="weixin-fill" color="#1BAB43" size="26"></uv-icon>
								</view>
							</button>
						</view>
					</view>
					<view class="absolute top-[0] left-0 w-[100%] z-[1]">
						<image :src="thumbImg(headtals.logo[0])" mode="aspectFill" class="w-[100%] h-[300rpx]"></image>
					</view>
					<view class="bakcrgb absolute top-[0] left-0 w-[100%] h-[300rpx] z-[1]">
					</view>
				</view>
				<view class="fixed top-0 w-[100%] bg-[#fff] z-[100] left-0"
					:style="[{'height': demoinfo.top + demoinfo.height+8+'px'}]" v-if="ishowinput">
					<view class="" :style="[{'width':windowWidth-demoinfo.width-20+'px'}]">
						<view class="flex justify-between items-center" :style="[{'margin-top': demoinfo.top+'px'}]">
							<view class="center z-[2]" @click="navback"
								:style="[{'height': 32 + 'px','padding-left':10 + 'px'}]">
								<uv-icon name="arrow-left" color="#000" size="20"></uv-icon>
							</view>
							<view class="serch flex items-center" @click="gettoserch">
								<view class="flex h-[32px] serchcont"
									:style="[{'width':windowWidth-demoinfo.width-100+'px'}]">
									<view class="">
										<image src="../static/homeimg/search.svg" mode="aspectFit"
											class="w-[24rpx] h-[24rpx]">
										</image>
									</view>
									<view class="ml-[10rpx] text-[28rpx]">
										搜索商品
									</view>
								</view>
							</view>
							<view class="">
								<button open-type="share" plain class="center weixin"
									style="border: 1px solid #F0F0F0;background-color: #fff;overflow: hidden;">
									<view @click="onShareAppMessage" open-type="share">
										<uv-icon name="weixin-fill" color="#1BAB43" size="26"></uv-icon>
									</view>
								</button>
							</view>
						</view>
					</view>
				</view>

				<view class="u-wrap relative " :style="{height: `calc(100vh - 1px)`}">
					<view class="contentsdf z-[2]">
						<view class="contents-head">
							<view class="logo felx">
								<view class="imglogo">
									<up-image :show-loading="true" :src="thumbImg(headtals.doorstepPhoto)"
										radius="10rpx" width="110rpx" height="110rpx">
										<template #error>
											<up-image :show-loading="true" radius="10rpx" width="110rpx" height="110rpx"
												mode="aspectFit">
											</up-image>
										</template>
									</up-image>
								</view>
								<view class="text-logo">
									<view class="name">
										{{headtals.storeName}}
									</view>
									<view class="time flex">
										<view class="flex">
											<view class="mr-[10rpx] relative top-[2rpx]">
												<image src="@/static/homeimg/time.svg" class="w-[24rpx] h-[24rpx]"
													mode="aspectFit"></image>
											</view>
											<view class="mr-[10rpx] center text-[#393939]">
												配送约 {{headtals.deliverTime}} <strong>分钟</strong> I
												月售 {{getsanum(headtals.monthSales)}}
											</view>
										</view>
									</view>
								</view>
							</view>
							<view class="shocng">
								<view class="xing" @click="shocang">
									<image
										:src="headtals.isFlow==1?'../static/homeimg/shocang.svg':'../static/homeimg/quxiao.svg'"
										mode="" class="w-[50rpx] h-[50rpx]"></image>
								</view>
								<view class="xintext">
									{{headtals.flowCount>999?'999+':headtals.flowCount}}人收藏
								</view>
							</view>
						</view>
						<view class="gogao mt-[10rpx]">
							<text
								class="text-[#393939] text-[26rpx] line-clamp-1">公告：{{headtals.storeConfig.notice==''?'暂无公告':headtals.storeConfig.notice}}</text>
						</view>

					</view>
					<!-- <u-gap :height="wrapHeight" v-if="showGap"></u-gap> -->
					<view class="u-wrap-tabs">
						<view class="flex mins px-[20rpx] w-[100%] bg-[#fff]" :class="tabindex == 0 ? 'minsbottom':''">
							<view class="huangk">
								<view class="flex  bg-white  pl-[14rpx] text-[32rpx] h-[90rpx] items-center font-[500]">
									<view @click="changetabls(index)" v-for="(item,index) in list1" :key="index"
										class="relative mr-[60rpx]">
										<view class="text-[#141516]">
											<view class="relative "
												:class="tabindex == index ? 'text-[#FE861C] font-bold' : ''">
												{{item.name}}
											</view>
											<view class="w-[47rpx] tbas" v-if="tabindex == index">
											</view>
										</view>
									</view>
								</view>
							</view>
							<view class="u-wrap-tabs-back flex items-center" v-show="showBackTop" @click="toTop">
								<u-icon name="arrow-upward"></u-icon>
							</view>
						</view><strong></strong>
					</view>
					<view class="u-menu-wrap" v-if="tabindex==0">
						<scroll-view :scroll-y="scrollY" scroll-with-animation class="u-tab-view menu-scroll-view"
							:scroll-top="scrollTop" :scroll-into-view="itemId">
							<view v-for="(item,index) in tabbar" :key="index" class="u-tab-item"
								:class="[current == index ? 'u-tab-item-active' : '']" @tap.stop="swichLeftMenu(index)">
								<view class="u-line-1 px-[20rpx]">{{item.goodsCateName}}</view>
							</view>
						</scroll-view>
						<view class="right-box flex-1">
							<u-sticky offsetTop="-200" bgColor="#FFFFFF">
								<!-- 	<u-tabs :list="subCate" :current="subCurrent" @change="subCateChange"
									keyName="goodsCateName" v-if="subCate.length>0"></u-tabs> -->
								<view class="flex overflow-x-scroll bg-[#fff] pb-[20rpx] pl-[30rpx] pt-[20rpx]"
									v-if="subCate.length>0">
									<view
										class="text-[26rpx] mr-[20rpx] rounded-[10rpx] h-[60rpx] flex justify-center items-center px-[27rpx]"
										@click="subCateChange(index)" v-for="(item,index) in subCate"
										:class="index==subCurrent?'text-[#FE861C] bg-[#FFF2E7]':'bg-[#F9F9F9]'">
										{{item.goodsCateName}}
									</view>
								</view>
								<view class="flex bg-[#fff] pb-[20rpx] pt-[20rpx] " v-else>
									<view
										class="text-[28rpx]  ml-[30rpx] rounded-[10rpx] h-[50rpx] flex justify-center items-center  bg-[#fff]">
										{{tabbar[current]?.goodsCateName}}
									</view>
								</view>
							</u-sticky>
							<scroll-view :scroll-y="scrollY" scroll-with-animation class="h-[calc(100%-10px)] bg-[#fff]"
								v-if="currentCate && currentCate.goods && currentCate.goods.length > 0" :enhanced="true"
								:bounces="false" :refresher-enabled="canPulldown" @refresherrefresh="onRefresh"
								:refresher-triggered="triggered" @refresherpulling="onPull" @refresherabort="onAbort"
								@scrolltolower="onScrolltolower" @touchmove="move" @touchstart="moveStart"
								@touchend="moveEnd"
								:style="{transform: 'translate(0px, '+scl.tranNum+'%) translateZ(0px)'}">
								<view class="page-view class-item list end">
									<view class="item-container">
										<template v-if="currentCate?.goods">
											<view class="px-[20rpx] pb-[40rpx]"
												v-for="(item,index) in currentCate.goods" :key="index">
												<view class="flex goods w-[100%]">
													<view class="goodsimg relative">
														<image class="goodsimg"
															:src="thumbImg(item.goodsImages!==null?item.goodsImages[0]:'')"
															mode="" @click="shopdetals(item)">
														</image>
														<view class="shopdow" v-if="item.goodsStatus==2">
															已下架
														</view>
														<view class="shoko" v-if="item.stockNum==0">
															已售罄
														</view>
													</view>
													<view class="goodstext w-[100%]">
														<view class="">
															<view class="text-head" @click="shopdetals(item)">
																{{item.goodsName}}
															</view>
															<view class="felx mt-[10rpx] salesNum"
																@click="shopdetals(item)">
																<view class="">
																	月售
																	{{getsanum(item.monthSales)}}
																</view>
																<view class="">
																	<!-- 库存{{item.stockNum}} -->
																</view>
															</view>
														</view>
														<view class="salesNum felx mounys">
															<view class="nummoyneys">
																￥{{item.goodsPrice}}
															</view>
															<view class="flex"
																v-if="item.specType==1 && item.batching==0 && isaddshop()">
																<view class="flex"
																	v-if="item.stockNum!==0 && item.goodsStatus!==2">
																	<view class="" @click="jaddshop(item)"
																		v-show="item.num>0">
																		<view class="jaddcar">
																			<u-icon name="minus" bold color="#FE861C"
																				top="" size="10"></u-icon>
																		</view>
																	</view>
																	<view class="numbershop" v-if="item.num>0">
																		{{item.num}}
																	</view>
																	<view class="addcars"
																		v-if="headtals.distance>headtals.storeConfig.deliveryRatio">
																		<view class="">
																			<u-icon name="plus" bold color="#fff"
																				size="12"></u-icon>
																		</view>
																	</view>
																	<view class="addcar" @click="addshop(item)" v-else>
																		<view class="">
																			<u-icon name="plus" bold color="#fff"
																				size="12"></u-icon>
																		</view>
																	</view>
																</view>
															</view>
															<view class="" v-else style="position: relative;">
																<!-- 	<view class=""
																	v-if="isaddshop()">
																	<view class="addcarsas"
																		v-if="item.stockNum!==0 && item.goodsStatus!==2">
																		选规格
																	</view>
																</view> -->
																<view class="" v-if="isaddshop()">
																	<view @click="select(item.specType,item.id,item)"
																		class="addcarsa"
																		v-if="item.stockNum!==0 && item.goodsStatus!==2">
																		选规格
																	</view>
																	<view class=""
																		style="position: absolute;top: -12rpx; right: -15rpx;">
																		<up-badge bg-color="#F12A2A"
																			v-if="results && Object.keys(results).length > 0"
																			type="error" max="99"
																			:value="results[item.id]"></up-badge>
																	</view>
																</view>

															</view>
														</view>
													</view>
												</view>
											</view>
										</template>
										<u-gap height="21"></u-gap>
									</view>
								</view>
								<view class="scorll"></view>
							</scroll-view>
						</view>
					</view>
					<view class="" v-if="tabindex==1">
						<bulisinfo :headtals="headtals" @isprop="isopenprop"></bulisinfo>
					</view>
					<view class="" v-if="tabindex==2">
						<Recharge :headtals="headtals"></Recharge>
					</view>

				</view>
				<!-- </u-sticky> -->
			</view>
		</scroll-view>
		<view
			class="fixed bottom-0 w-[100%] h-[140rpx] bg-[#000] opacity-[0.6] px-[50rpx] justify-between flex items-center text-[#fff]"
			v-if="!isaddshop()">
			<view class="text-[40rpx]" :class="headtals.businessStatus==2?'w-[100%] text-center':''">
				{{headtals.businessStatus==1?'无法配送到当前位置':"门店休息中"}}
			</view>
			<view
				class="border-[#fff] border-[1rpx]  h-[66rpx] flex justify-center items-center w-[180rpx] text-[30rpx] rounded-[66rpx]"
				@click="navtos" v-if="headtals.businessStatus==1">
				更换地址
			</view>
		</view>
	</page-meta>
	<WuSkus :model-value="skuShow" class="popupShow" :defaultNum="defaultNum" :data="skus" :themeColor="[254, 134, 28]"
		btnConfirmText="加入购物车" :defaultCover="imgdang" :specType="specTypedang" :prices='pricedang'
		:batchsprice="batchingId" :stockNum="dangstockNum" notSelectSku="请选择完整的商品信息" @confirm="confirm"
		@close="skuShow = false" @skuChange="skuChange" :yiertype="1" @numChange="numChange">
		<template v-slot:batching>
			<view class="mt-[20rpx] mb-[10rpx]" v-if="bachlist.length>0">
				<view class="text-[30rpx]">配料</view>
				<view class="flex flex-wrap">
					<view class="flex" v-for="(item,index) in bachlist" :key="index"
						:class="havebatch(item)?'boxbachtactive':'boxbacht'" @click="choseback(item)">
						<view class="rightbodr">
							{{item.batchingName}}
						</view>
						<view class="lingsd flex items-center">
							￥{{item.price}}
						</view>
					</view>
				</view>
			</view>
		</template>
	</WuSkus>
	<shopbuttom v-if="tabindex==0 &&  isaddshop()" :headtals="headtals"
		:shopnums="shopnum" :pagepricenum="pagepricenum" :cartDetails="cartDetails" @changenum='changenums'
		@isprop="isopenprop"></shopbuttom>
</template>
<script>
	// import WuSkus from "@/components/wu-sku/components/wu-sku/wu-sku.vue"
	import WuSkus from "@/components/sku/sku.vue"
	import Recharge from "./components/Recharge.vue"
	import bulisinfo from "./components/buliceinfo.vue"
	import shopbuttom from "./components/shopbuttom.vue"
	import {
		isEqualArray
	} from "@pureadmin/utils"
	import {
		storenamedetal,
		bulisliststore,
		applystorestore,
		storebalance,
		storecartdetals,
		storecart,
		gooddetals,
		goodscatelist,
		deleteGoods,
		decreaseGoods,
		goodattr,
		storecollect,
		storecollectnum,
		storevlueuserbills,
		storeconcern,
		vipaccount,
		storegoodslist,
		cancelcollect
	} from "@/api/home.js"
	import {
		useStore
	} from '@/stores/user.js'
	import {
		useAppStore
	} from "@/stores/app.js"
	const store = useStore();
	import {
		defineStore
	} from 'pinia';
	export default {
		components: {
			Recharge,
			bulisinfo,
			shopbuttom,
			WuSkus
		},
		data() {
			return {
				defaultNum: 0, //默认数量
				itemCount: {}, //当前商品详情
				selectsku: {}, //当前sku
				scrollToTop: 0, //页面滚动位置
				isscollhidden: false,
				results: null,
				showGap: false,
				wrapHeight: 0,
				tabindex: 0,
				originWrapTop: 200,
				wrapTop: 200,
				canOffset: 3,
				list1: [{
					name: '商品',
				}, {
					name: '商家',
				}, {
					name: '储值'
				}],
				// canPulldown: false,
				scrollY: false,
				triggered: false,
				_freshing: false,
				_pulling: false,
				limit: 10,
				pagepricenum: 0,
				scrollTop: 0, //tab标题的滚动条位置
				current: 0, // 左侧菜单索引,预设当前项的值
				subCurrent: 0, // 右侧子菜单索引,预设当前项的值
				itemId: '', // 栏目右边scroll-view用于滚动的id
				tabbar: [],
				scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
				subCate: [],
				currentCate: null,
				initPage: {
					isEnd: false,
					page: 0,
					hasInit: true,
					goods: []
					// limit: 10
				},
				scl: {
					right: 0, //容器距离，判断是否达到最右侧
					bottom: 0, //容器距离，判断是否达到最右侧
					width: 0, //右滑块的width
					tranNum: 0,
					tx: 0, //滑动位置
					lastX: 0,
					lastY: 0,
					inter: null,
					sate: false, //状态
				},
				storeid: 0,
				deliveryPrice: 0,
				storeName: "", //名字
				deliveryType: "",
				demoinfo: uni.getMenuButtonBoundingClientRect(),
				windowHeight: uni.getSystemInfoSync().windowHeight, //屏幕高度
				windowWidth: uni.getSystemInfoSync().windowWidth, //屏幕高度
				headtals: {
					distance: 0,
					monthSales:0,
					storeConfig: {
						notice: "",
						deliveryRatio: ""
					},
					logo: []
				},
				// ishowinput: false,
				shopnum: 0, ////商品数量 
				cartDetails: {
					data: 0,
					list: {
						data: []
					},
					list2: []
				},
				bachlist: [], //配料
				specTypedang: 0,
				pricedang: 0,
				dangstockNum: 0,
				dangweight: "",
				imgdang: '',
				skuShow: false,
				skus: [], //商品sku列表
				// bachlist:[],
				batchingId: [],
				dangshopId: 0,
			}
		},
		onShow() {
			this.$nextTick(() => {
				this.cardetaslist()
				this.storedetals()
			})
		},
		onLoad(e) {
			this.storeid = e.id || e.cq
			this.wrapHeight = useAppStore().navigationBarAndStatusBarHeight
			if (e.cq > 0) {
				if (uni.getStorageSync('loginTokenKey')) {
					storeconcern({
						storeId: e.cq
					}).then(res => {
						if (res.code == 200) {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
							this.storedetals()
						} else if (res.code == 201) {
							uni.removeStorageSync('loginTokenKey')
							uni.navigateTo({
								url: "/pages/index/followinterest?id=" + e.cq
							})
						}
					})
					this.storeid = e.cq
					//获取分类列表
					this.getcatelist(this.storeid)
					//门店详情
					storenamedetal({
						storeId: e.cq,
						lat: store.lat,
						lng: store.lng,
					}).then(res => {
						if (res.code == 200) {
							this.getshoc()
							this.storeName = res.result.name
							this.deliveryType = res.result.storeConfig.deliveryType
							uni.setStorageSync('deliveryType', res.result.storeConfig.deliveryType)
							Object.assign(this.headtals, res.result)
							if (this.headtals.storeConfig.status == 2) {
								this.list1.splice(2, 1)
							}
							Object.assign(store.doorinfo, res.result)
							// cardetaslist()
							applystorestore({
								storeId: e.cq,
								shopId: this.headtals.shopId
							}).then(res => {
								if (res.code == 200) {
									this.storlist = res.result.data
								}
							})
						}
					})
				} else {
					uni.navigateTo({
						url: "/pages/index/followinterest?id=" + e.cq
					})
				}
			} else {
				this.storeid = e.id
				//获取分类列表
				this.deliveryPrice = e.deliveryPrice
				//门店详情
				storenamedetal({
					storeId: e.id,
					lat: store.lat,
					lng: store.lng,
				}).then(res => {
					if (res.code == 200) {
						this.storeName = res.result.name
						this.deliveryType = res.result.storeConfig.deliveryType
						uni.setStorageSync('deliveryType', this.deliveryType)
						Object.assign(this.headtals, res.result)
						if (this.headtals.storeConfig.status == 2) {
							this.list1.splice(2, 1)
						}
						Object.assign(store.doorinfo, res.result)
					}
				})
			}
			//获取分类
			this.getcatelist(this.storeid)
		},
		onPageScroll(e) {
			if (e.scrollTop > 50) {
				this.ishowinput = true
			} else {
				this.ishowinput = false
			}
			this.getWrapTop()
		},
		computed: {
			// showBackTop() {
			// 	return this.wrapTop < (this.originWrapTop - 30)
			// }
			ishowinput() {
				return this.wrapTop < this.wrapHeight
			},
			showBackTop() {
				return this.wrapTop < (this.originWrapTop - 30)
			},
			canPulldown() {
				return (this.current > 0 || this.subCurrent > 0) && this.containerScroll === false
			},
			containerScroll() {
				return this.wrapTop > 0 || (this.current === 0 && this.subCurrent === 0)
			}
		},
		mounted() {
			this.$nextTick(() => {
				this.getWrapTop()
				this.setOriginWrapTop()
				this.cardetaslist()
			})
		},
		methods: {
			//判断是否可以添加购物车
			isaddshop() {
				if (this.headtals.businessStatus == 1 && this.headtals.distance < this.headtals.storeConfig
					.deliveryRatio) {
					store.isaddcart = 1
					return true
				} else {
					store.isaddcart = 0
					return false
				}

			},
			//数量改变
			numChange(n) {
				this.defaultNum = n
			},
		// sku发生改变事件, 选择完整的sku则回返回 否则sku的值为{}
		skuChange(sku) {
			let that = this
			this.defaultNum = 0
			if (sku) {
				this.selectsku = sku
			}
			if (this.cartDetails.list2.some((item) => item.id === this.itemCount.id) && this.specTypedang == 2) {
				for (let i = 0; i < this.cartDetails.list2.length; i++) {
					if (this.itemCount.id == this.cartDetails.list2[i]?.id && sku?.id == this.cartDetails.list2[i]
						.goodsStock
						.id) {
						if (this.cartDetails.list2[i].batchingIds == null) {
							if (this.batchingId.length < 1) {
								this.defaultNum = this.cartDetails.list2[i].num
								return;
							} else {
								this.defaultNum = 0
							}
						} else {
							if (isEqualArray(this.cartDetails.list2[i]?.batchingIds, this.batchingId)) {
								this.defaultNum = this.cartDetails.list2[i].num
								return;
							} else {
								this.defaultNum = 0
							}
						}
					} else {
						this.defaultNum = 0
					}
				}
			} else if (this.cartDetails.list2.some((item) => item.id === this.itemCount.id) && this.specTypedang ==
				1) {
				for (let i = 0; i < this.cartDetails.list2.length; i++) {
					if (this.cartDetails.list2[i]?.batchingIds == null && this.batchingId.length < 1 && this
						.cartDetails
						.list2[i].id == this.itemCount.id) {
						this.defaultNum = this.cartDetails.list2[i].num
						return;
					} else if (isEqualArray(this.cartDetails.list2[i]?.batchingIds, this.batchingId) && this
						.cartDetails
						.list2[i].id == this.itemCount.id) {
						this.defaultNum = this.cartDetails.list2[i].num
						return;
					} else {
						that.defaultNum = 0
					}
		
				}
			} else {
				this.defaultNum = 0
			}
		
		},
			thumbImg(url) {
				return url + '?imageView2/0/format/webp/q/75'
			},
			onContainerScroll() {
				this.getWrapTop()
			},
			//打开滚动条
			isopenprop(e) {
				console.log(e, '滚动条')
				this.isscollhidden = e
			},
			//判断配料是否被选中
			havebatch(item) {
				let ishabatchings = this.batchingId.filter(items => items.batchingId == item.batchingId)
				if (ishabatchings.length > 0) {
					return true
				} else {
					false
				}
			},
			//选择配料
			choseback(item) {
				let ishabatching = this.batchingId.filter(items => items.batchingId == item.batchingId)
				if (ishabatching.length !== 0) {
					this.batchingId = this.batchingId.filter(items => items.batchingId !== item.batchingId)
				} else {
					this.batchingId.push({
						batchingId: item.batchingId,
						batchingName: item.batchingName,
						price: item.price,
						stockNum:item.stockNum
					})
				}
				this.batchingId.value = this.batchingId.sort((a, b) => a.batchingId - b.batchingId);
				this.skuChange(this.selectsku)
			},
			//清空购物车
			delcart() {
				deleteGoods({
					storeId: this.storeid
				}).then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: "购物车已清空",
							icon: 'none'
						})
						this.cardetaslist()

					}
				}).catch(err => {
					console.log("异常", err)
				})
			},
			changenums(e) {
				this.cardetaslist()
				this.results = {}
				setTimeout(() => {
					if (this.cartDetails.list2.length > 0 && this.currentCate.goods.length > 0) {
						this.cartDetails.list2.forEach((item => {
							this.currentCate.goods.forEach(items => {
								if (item.id == items.id) {
									items.num = item.num
								}
							})
						}))
					} else if (this.cartDetails.list2.length == 0) {
						this.currentCate.goods.forEach(items => {
							items.num = 0
						})
					}
				}, 100)

			},
			//添加单规格商品
			addshop(item) {
				if (item.num == undefined || item.num == NaN) {
					item.num = 1
				} else {
					item.num++
				}
				gooddetals({
					goodsId: item.id,
					storeId: this.storeid
				}).then(res => {
					if (res.code == 200) {
						const goodsInfo = res.result.goodsInfo
						let data = {
							storeId: this.headtals.id,
							goods: [{
								num: item.num,
								id: goodsInfo.id,
								cateId: goodsInfo.cateId,
								goodsCateId: goodsInfo.goodsCateId,
								specType: goodsInfo.specType,
								batchingIds: null,
								storeId: this.headtals.id,
								goodsName: goodsInfo.goodsName,
								packagePrice: goodsInfo.packagePrice,
								content: goodsInfo.content,
								goodsPrice: item.goodsPrice,
								weight: goodsInfo.weight,
								goodsImages: goodsInfo.goodsImages
							}]
						}
						if (this.cartDetails.list2.length < 1) {
							storecart(data).then(res => {
								if (res.code == 200) {
									this.cardetaslist()
								}
							})
						} else {
							this.cartDetails.list2.forEach((item, index) => {
								if (item.id == goodsInfo.id) {
									this.cartDetails.list2.splice(index, 1)
								}
							})
							this.cartDetails.list2.push(data.goods[0])
							storecart({
								storeId: this.headtals.id,
								goods: this.cartDetails.list2
							}).then(res => {
								if (res.code == 200) {
									this.cardetaslist()
								} else {
									uni.showToast({
										icon: 'none',
										title: res.msg
									})
								}
							})
						}

					}
				})
			},
			//减少单规格商品
			jaddshop(item) {
				let that = this
				if (item.num > 0) {
					item.num--
				}
				console.log("购物车", that.cartDetails.list2.length)
				switch (true) {
					case that.cartDetails.list2.length == 1:
						that.cartDetails.list2.forEach((items, index) => {
							console.log(item.id, items.id)
							if (item.id == items.id) {
								items.num--
								if (items.num == 0) {
									that.delcart()
									// that.cartDetails.list2.splice(index, 1)
								} else {
									storecart({
										storeId: this.storeid,
										goods: that.cartDetails.list2
									}).then(res => {
										if (res.code == 200) {
											this.cardetaslist()
										}
									})
								}
							}
						})
						return;
					case that.cartDetails.list2.length !== 1:
						for (let i = 0; i <= that.cartDetails.list2.length; i++) {
							console.log(that.cartDetails.list2, i, "的JFK")
							if (item.id == that.cartDetails.list2[i].id && item.num == 0) {
								that.cartDetails.list2.splice(i, 1)
								storecart({
									storeId: that.storeid,
									goods: that.cartDetails.list2
								}).then(res => {
									if (res.code == 200) {
										that.cardetaslist()
									}
								})
								return;
							} else if (item.id == that.cartDetails.list2[i].id && item.num !== 0) {
								that.cartDetails.list2[i].num--
								storecart({
									storeId: that.storeid,
									goods: that.cartDetails.list2
								}).then(res => {
									if (res.code == 200) {
										that.cardetaslist()
									}
								})
								return;

							}
						}

				}
			},
			//获取购物车详情
			cardetaslist() {
				storecartdetals({
					storeId: this.storeid
				}).then(res => {
					if (res.code == 200 && res.result.cart !== null) {
						this.cartDetails.data = res.result.cart.totalAmount
						this.cartDetails.list = res.result.cart
						this.cartDetails.list2 = res.result.cart.data
						this.shopnum = 0
						this.pagepricenum = 0
						res.result.cart.data.forEach(item => {
							this.shopnum += item.num //商品总数
							this.pagepricenum += item.num * item.packagePrice
						})
						this.results = res.result.cart.data.reduce((obj, item) => {
							const {
								id,
								num
							} = item;
							if (obj[id]) {
								obj[id] += num;
							} else {
								obj[id] = num;
							}
							return obj;

						}, {});
					} else {
						this.cartDetails.data = 0
						this.cartDetails.list2 = []
						this.cartDetails.list.data = []
						// uni.hideLoading();
					}

				}).catch(err => {
					console.log(err)
				})
			},
			//收藏或取消收藏
			shocang() {
				if (this.headtals.isFlow == 1) {
					let that = this
					uni.showModal({
						title: "收藏",
						content: "您确定取消收藏吗？",
						success: function(res) {
							if (res.confirm) {
								cancelcollect({
									storeId: that.storeid
								}).then(res => {
									if (res.code == 200) {
										uni.showToast({
											icon: "none",
											title: res.msg
										})
										that.storedetals()
									} else {
										uni.showToast({
											icon: "none",
											title: res.msg
										})
									}
								})
							}
						}
					})
				} else {
					this.getshoc()
				}
			},
			//去搜索
			gettoserch() {
				uni.navigateTo({
					url: "/pages/index/serch?name=" + this.headtals.storeName + '&id=' + this.headtals.id +
						"&startDeliveryPrice=" + this.headtals.storeConfig.startDeliveryPrice
				})
			},
			//获取门店详情
			storedetals() {
				//门店详情
				storenamedetal({
					storeId: this.storeid,
					lat: store.lat,
					lng: store.lng,
				}).then(res => {
					if (res.code == 200) {
						this.deliveryType = res.result.storeConfig.deliveryType
						uni.setStorageSync('deliveryType', this.deliveryType)
						Object.assign(this.headtals, res.result)
						if (this.headtals.storeConfig.status == 2) {
							this.list1.splice(2, 1)
						}
						Object.assign(store.doorinfo, res.result)
					}
				})
			},
			getshoc() {
				console.log(111111, "进来了")
				storecollect({
					storeId: this.storeid
				}).then(res => {
					if (res.code == 200) {
						this.storedetals()
					} else {
						uni.showToast({
							icon: "none",
							title: res.msg
						})
					}
				})
			},
			//返回
			navback() {
				uni.switchTab({
					url: "/pages/index/index"
				})
			},
			//tab改变
			changetabls(e) {
				this.tabindex = e
			},
			//获取分类
			getcatelist(id) {
				goodscatelist({
					storeId: id
				}).then(res => {
					if (res.code == 200) {
						this.tabbar = res.result.cateTree
						if (res.result.cateTree.length > 0) {
							let f = this.tabbar[0]
							this.setCates(f)
						}
					}
				})
			},
			setOriginWrapTop() {
				this.getDom(".u-wrap", res => {
					this.originWrapTop = res.top.toFixed(0)
				})
			},
			getWrapTop() {
				this.getDom(".u-wrap", res => {
					this.wrapTop = res.top.toFixed(0)
					// this.scrollY = this.wrapTop < (this.wrapHeight)
					this.scrollY = this.wrapTop < this.canOffset
				})
			},
			toTop() {
				this.current = 0
				this.subCurrent = 0
				setTimeout(() => {
					this.scrollToTop = this.scrollToTop === 0 ? 0.1 : 0
				}, 50)
			},
			// 右侧滚动到底部 加载列表数据
			onScrolltolower() {
				this.findGoods()
			},
			//下啦触发
			onPull() {
				if (this.current === 0 && this.subCurrent === 0) return
				if (!this.triggered) this.triggered = true; //界面下拉触发，triggered可能不是true，要设为true  
				this._pulling = true
			},
			onAbort() {
				this._pulling = false
			},
			//下拉
			onRefresh() {
				if (this._freshing) return;
				if (this.current === 0 && this.subCurrent === 0) return
				this._freshing = true;
				if (!this.triggered) this.triggered = true; //界面下拉触发，triggered可能不是true，要设为true  
				this.stopRefresh().then(() => {
					// this.triggered = false
					//返回上一个子分类，如果是第一个子分类，则左侧返回上一个分类
					if (this.subCurrent === 0) {
						//左侧分类返回上一个
						this.swichLeftMenu(this.current - 1)
					} else {
						//子分类返回上一个
						this.swichSubMenu(this.subCurrent - 1)
					}

				})
			},
			async stopRefresh() {
				this._freshing = false
				this._pulling = false
			},
			navtos() {
				uni.navigateTo({
					url: "/pages/index/address"
				})
			},
			// 设置分类
			setCates(cate) {
				if (cate?.childs !== null && cate.childs?.length > 0) {
					this.setCurrentCate(cate.childs[0])
					this.swichSubMenu(0)
					this.findGoods()
					this.subCate = cate.childs
				} else {
					this.setCurrentCate(cate)
					this.findGoods()
				}

			},
			//已售数量展示
			getsanum(e){
				switch (true) {
					case e <= 100:
						return e;
					case e <= 1000:
						return parseInt(e / 100)*100 + '+';
					case e <= 10000:
						return parseInt(e / 1000)*1000 + '+';
					case e > 10000:
						return 9999 + '+';
				}
			},
			//跳转商品详情
			shopdetals(item) {
				uni.navigateTo({
					url: "/pages/index/buillsdetals?id=" + item.id + "&storeId=" + item.storeId + "&delivertime=" +
						this.headtals.deliverTime
				})
			},

			//设置当前选中分类

			setCurrentCate(cate) {
				this.currentCate = cate
				Object.assign(this.currentCate, this.initPage)
			},

			//查询商品
			findGoods() {
				let that = this
				if (this.currentCate.isEnd && this.currentCate.goods && this.currentCate.goods.length > 0) {
					return
				}
				this.currentCate.page++
				storegoodslist({
					storeId: this.storeid,
					subCateId: this.currentCate.parentId ? this.currentCate.id : 0,
					goodsCateId: this.currentCate.parentId ? 0 : this.currentCate.id,
					page: this.currentCate.page,
					limit: this.limit,
				}).then(res => {
					let data = res.result.data
					if (data.length === 0 || data.length < this.limit) {
						this.currentCate.isEnd = true
						this.changenums()
					}
					if (!this.currentCate.goods) {
						this.currentCate.goods = data
					} else {
						this.currentCate.goods = this.currentCate.goods.concat(data)
						this.changenums()
					}


				})
			},
			//右侧滚动到底部,如果商品列表加载完，则跳转下一个分类，否则继续加载商品
			changeCate() {
				if (this.currentCate.isEnd) {
					//如果是子分类
					//是否还有下一个子类，没有则左侧tab跳至下一个
					if (this.currentCate.parentId > 0) {
						// 判断当前子类是否是最后一个，如果是则左侧分类跳到下一个，否则右侧分类切换下一个
						if (this.subCurrent === (this.subCate.length - 1)) {
							//如果左侧也是最后一条则不跳转
							if (this.current === (this.tabbar.length - 1)) {
								return
							}
							// this.subCurrent = 0
							this.swichLeftMenu(this.current + 1)
						} else {
							this.swichSubMenu(this.subCurrent + 1)
							// this.subCurrent++
						}
					} else {
						// 如果 parentId =0 则直接左侧tab跳至下一个
						let i = this.current + 1
						if (i > this.tabbar.length - 1) return
						this.swichLeftMenu(i)
					}
				}
			},
			// 点击左边的栏目切换
			swichLeftMenu(index) {
				if (index == this.current) return;
				this.subCate = []
				this.subCurrent = 0
				this.current = index;
				this.setCates(this.tabbar[index])

				if (index == this.current) return;
				this.subCate = []
				this.subCurrent = 0
				this.current = index;
				this.setCates(this.tabbar[index])
			},
			//切换右侧子类
			swichSubMenu(subIndex) {
				if (subIndex == this.subCurrent) return;
				this.subCurrent = subIndex
				this.setCurrentCate(this.subCate[subIndex])
				this.findGoods()
			},
			//子类tab 改变事件
			subCateChange(index) {
				this.swichSubMenu(index)
				// this.subCurrent = e.index
			},
			getDom(dom, callback) {
				let query = uni.createSelectorQuery().in(this);
				query.select(dom).boundingClientRect(res => {
					callback(res);
				}).exec();
			},
			//当前列表可以move的时候列表已经加载完成，这时可以跳转到下一个分类列表，下一个子类或者左侧下一个分类
			//手指滑动指定距离后执行
			move(event) {
				console.log("-----------");
				if (this.wrapTop > this.canOffset) return
				if (!this.currentCate.isEnd) return
				let currentX = event.changedTouches[0].pageX;
				let currentY = event.changedTouches[0].pageY;
				let ty = currentX - this.scl.lastX; //向左滑动:tx<0 ,向右滑动tx > 0
				let tx = currentY - this.scl.lastY;

				if (Math.abs(tx) <= Math.abs(ty)) { //上下方向滑动
					return;
				}
				this.getDom('.list', res => {
					this.scl.right = res.bottom.toFixed(0);
				})
				//底部加载 view高度 自定义设置
				if (this.scl.width == 0) {
					this.getDom('.scorll', res => {
						this.scl.width = res.height.toFixed(0);
					});
				}
				this.getDom('.end', res => {
					if (this.scl.right == res.bottom.toFixed(0)) {
						this.scl.tx = this.scl.tx + tx;
						let scale = this.scl.width > 0 ? -(this.scl.right / this.scl.width) * 100 : 0; //计算占比
						this.scl.tx = this.scl.tx < scale ? scale : this.scl.tx;
						if (this.scl.tx < 0) {
							if (this.scl.tx < -80) { //这里的80按需求定(手指滑动多少距离执行)
								this.scl.sate = true;
							} else {
								this.scl.sate = false;
							}
							this.scl.tranNum = this.scl.tx * 0.04;
						}
					}
				});
				//将当前坐标进行保存以进行下一次计算
				this.scl.lastX = currentX;
				this.scl.lastY = currentY;
			},
			//滑动结束
			//如果抬手则切换分类
			moveEnd(event) {
				console.log('moveEndmoveEndmoveEnd', this._pulling);
				//如果是下是下拉触发则返回
				if (this._pulling) return
				if (this.scl.tx <= 0) {
					this.scl.inter = setInterval(() => {
						this.scl.tx = this.scl.tx + 10;
						this.scl.tx = this.scl.tx >= 0 ? 0 : this.scl.tx;
						this.scl.tranNum = this.scl.tx * 0.1;
						if (this.scl.tx == 0) {
							clearInterval(this.scl.inter);
						}
					}, 1);
				} else {
					this.scl.tx = 0;
					this.scl.inter && clearInterval(this.scl.inter);
				}
				if (this.scl.sate) { //执行操作
					this.scl.sate = false;
					//切换分类
					if (this._pulling) return
					//切换分类
					if (!this.scrollY) return
					this.changeCate()
				}
			},


			moveStart(event) {
				this.scl.lastX = event.changedTouches[0].pageX;
				this.scl.lastY = event.changedTouches[0].pageY;
			},
			// sku确认事件
			confirm(e) {
				if (!this.itemCount.id) {
					return;
				}
				if (e.num == 0) {
					switch (true) {
						case this.cartDetails.list2.length == 1:
							this.cartDetails.list2.forEach((items, index) => {
								if (this.itemCount.id == items.id) {
									this.delcart()
								}
							})
							return;
						case this.cartDetails.list2.length !== 1:
							for (let i = 0; i < this.cartDetails.list2.length; i++) {
								let arr1 = this.cartDetails.list2[i].batchingIds == null ? [] : this.cartDetails.list2[i]
									.batchingIds
								let arr2 = this.batchingId
								if (this.itemCount.data.id == this.cartDetails.list2[i].id && isEqualArray(arr1, arr2)) {
									this.cartDetails.list2.splice(i, 1)
									storecart({
										storeId: this.storeid,
										goods: this.cartDetails.list2
									}).then(res => {
										if (res.code == 200) {
											this.cardetaslist()
										}
									})
									return;
								}
							}
					}
				} else {
					//获取商品详情
					gooddetals({
						goodsId: this.itemCount.id,
						storeId: this.storeid
					}).then(res => {
						if (res.code == 200) {
							let bachlists = []
							if (this.batchingId.length > 0) {
								bachlists = this.batchingId
							} else {
								bachlists = null
							}
							const goodsInfo = res.result.goodsInfo
							let data = {
								storeId: this.headtals.id,
								goods: [{
									num: e.num,
									// skuId: e.sku.id,
									storeId: this.headtals.id,
									id: goodsInfo.id,
									categoryId: goodsInfo.categoryId,
									goodsCateId: goodsInfo.goodsCateId,
									batchingIds: bachlists,
									specType: goodsInfo.specType,
									goodsName: goodsInfo.goodsName,
									packagePrice: goodsInfo.packagePrice,
									content: goodsInfo.content,
									goodsPrice: this.specTypedang == 2 ? e.sku.price : this.pricedang,
									goodsImages: goodsInfo.goodsImages,
									weight: this.specTypedang == 2 ? e.sku.weight : this.dangweight,
									goodsStock: this.specTypedang == 2 ? {
										id: e.sku.id,
										suk: e.sku.suk,
										weight: this.specTypedang == 2 ? e.sku.weight : this
											.dangweight
									} : {}
								}]
							}
							//判断是否已经添加过同样的商品
							switch (true) {
								case this.cartDetails.list2.length < 1: //购物车无数据
									storecart(data).then(res => {
										if (res.code == 200) {
											this.cardetaslist()
										}
									})
									return;
								case this.cartDetails.list2.length > 0: //购物车有数据
									let isadd = false
									let filteredArr = this.cartDetails.list2.filter(function(item) { //过滤商品是否有相同的id
										return item.id === goodsInfo.id;
									});
									if (goodsInfo.specType == 2 && filteredArr.length > 0) { //判断商品相同的商品是否为多规格
										let isalltrue = true
										for (let i = 0; i < this.cartDetails.list2.length; i++) {
											if (this.cartDetails.list2[i].batchingIds == null && this.batchingId
												.length ==
												0 && this.cartDetails.list2[i].id == goodsInfo.id && e.sku.id ==
												this.cartDetails
												.list2[i].goodsStock.id) {
												this.cartDetails.list2[i].num = data.goods[0].num
												storecart({
													storeId: this.headtals.id,
													goods: this.cartDetails.list2,
												}).then(res => {
													if (res.code == 200) {
														this.cardetaslist()
													}
												})
												return;
											} else if (isEqualArray(this.cartDetails.list2[i].batchingIds, this
													.batchingId) && this.cartDetails.list2[i].id == goodsInfo.id &&
												e.sku.id ==
												this.cartDetails.list2[i].goodsStock.id) {
												this.cartDetails.list2[i].num = data.goods[0].num
												storecart({
													storeId: this.headtals.id,
													goods: this.cartDetails.list2,
												}).then(res => {
													if (res.code == 200) {
														this.cardetaslist()
													}
												})
												return;
											} else if (this.cartDetails.list2[i].id == goodsInfo.id && !
												isEqualArray(
													this.cartDetails.list2[i].batchingIds, this.batchingId) && i ==
												this.cartDetails.list2.length - 1 && e.sku.id == this.cartDetails
												.list2[i]
												.goodsStock.id) {
												this.cartDetails.list2.push(data.goods[0])
												storecart({
													storeId: this.headtals.id,
													goods: this.cartDetails.list2
												}).then(res => {
													if (res.code == 200) {
														this.cardetaslist()
													} else {
														uni.showToast({
															icon: 'none',
															title: res.msg
														})
													}
												})
												return;
											} else if (this.cartDetails.list2[i].id == goodsInfo.id && !
												isEqualArray(
													this.cartDetails.list2[i].batchingIds, this.batchingId) && i ==
												this.cartDetails.list2.length - 1) {
												this.cartDetails.list2.push(data.goods[0])
												storecart({
													storeId: this.headtals.id,
													goods: this.cartDetails.list2
												}).then(res => {
													if (res.code == 200) {
														this.cardetaslist()
													} else {
														uni.showToast({
															icon: 'none',
															title: res.msg
														})
													}
												})
												return;
											} else if (this.cartDetails.list2[i].id == goodsInfo.id &&
												isEqualArray(
													this.cartDetails.list2[i].batchingIds, this.batchingId) && i ==
												this.cartDetails.list2.length - 1 && e.sku.id !== this.cartDetails
												.list2[i]
												.goodsStock.id) {
												this.cartDetails.list2.push(data.goods[0])
												storecart({
													storeId: this.headtals.id,
													goods: this.cartDetails.list2
												}).then(res => {
													if (res.code == 200) {
														this.cardetaslist()
													} else {
														uni.showToast({
															icon: 'none',
															title: res.msg
														})
													}
												})
												return;
											}

										}
									} else if (goodsInfo.specType == 1 && filteredArr.length > 0) {
										for (let i = 0; i < this.cartDetails.list2.length; i++) {
											if (this.cartDetails.list2[i].batchingIds == null && this.batchingId
												.length ==
												0 && this.cartDetails.list2[i].id == goodsInfo.id) {
												this.cartDetails.list2[i].num = data.goods[0].num
												storecart({
													storeId: this.headtals.id,
													goods: this.cartDetails.list2,
												}).then(res => {
													if (res.code == 200) {
														this.cardetaslist()
													}
												})
												return;
											} else if (isEqualArray(this.cartDetails.list2[i].batchingIds, this
													.batchingId) && this.cartDetails.list2[i].id == goodsInfo.id) {
												this.cartDetails.list2[i].num = data.goods[0].num
												storecart({
													storeId: this.headtals.id,
													goods: this.cartDetails.list2,
												}).then(res => {
													if (res.code == 200) {
														this.cardetaslist()
													}
												})
												return;
											} else if (this.cartDetails.list2[i].id == goodsInfo.id && !
												isEqualArray(
													this.cartDetails.list2[i].batchingIds, this.batchingId) && i ==
												this.cartDetails.list2.length - 1) {
												this.cartDetails.list2.push(data.goods[0])
												storecart({
													storeId: this.headtals.id,
													goods: this.cartDetails.list2
												}).then(res => {
													if (res.code == 200) {
														this.cardetaslist()
													} else {
														uni.showToast({
															icon: 'none',
															title: res.msg
														})
													}
												})
												return;
											}

										}
									} else {
										this.cartDetails.list2.push(data.goods[0])
										storecart({
											storeId: this.headtals.id,
											goods: this.cartDetails.list2
										}).then(res => {
											if (res.code == 200) {
												this.cardetaslist()
											} else {
												uni.showToast({
													icon: 'none',
													title: res.msg
												})
											}
										})
									}

									return
							}




						}
					})
				}
			},
			select(item, id, e) {
				this.skus = []
				this.batchingId = []
				this.itemCount = e
				this.dangshopId = id
				if (item == 2) {
					gooddetals({
						goodsId: id,
						storeId: this.storeid
					}).then(res => {
						if (res.code == 200) {
							if (res.result.goodsInfo.specType == 2) {
								this.skus = []
								let es = res.result.goodsAttr.length
								res.result.goodsStock.forEach((item, index) => {
									if (es > 1) {
										this.skus.push({
											packagePrice: item.packagePrice,
											id: item.id,
											price: item.price,
											suk: item.suk,
											weight: item.weight,
											stock: item.stock,
											sku_attrs: {
												[res.result.goodsAttr[0].attrName]: item.skuOne,
												[res.result.goodsAttr[1].attrName]: item.skuTwo
											}
										})
									} else {
										this.skus.push({
											packagePrice: item.packagePrice,
											id: item.id,
											weight: item.weight,
											suk: item.suk,
											price: item.price,
											stock: item.stock,
											sku_attrs: {
												[res.result.goodsAttr[0].attrName]: item.skuOne
											}
										})
									}

								})
							} else {
								this.skus = []
							}
							this.bachlist = res.result.batchings
							this.specTypedang = res.result.goodsInfo.specType
							this.pricedang = res.result.goodsInfo.goodsPrice
							this.dangstockNum = res.result.goodsInfo.stockNum
							this.dangweight = res.result.goodsInfo.weight
							this.imgdang = res.result.goodsInfo.goodsName
							this.skuShow = true
						}
					})
				} else {
					gooddetals({
						goodsId: id,
						storeId: this.storeid
					}).then(res => {
						if (res.code == 200) {
							this.skuShow = true
							this.specTypedang = res.result.goodsInfo.specType
							this.pricedang = res.result.goodsInfo.goodsPrice
							this.dangstockNum = res.result.goodsInfo.stockNum
							this.bachlist = res.result.batchings
							this.dangweight = res.result.goodsInfo.weight
							this.imgdang = res.result.goodsInfo.goodsName
							if (res.result.goodsInfo.specType == 2) {
								this.skus = []
								let es = res.result.goodsAttr.length
								res.result.goodsStock.forEach((item, index) => {
									if (es > 1) {
										this.skus.push({
											packagePrice: item.packagePrice,
											id: item.id,
											price: item.price,
											stock: item.stockNum,
											weight: item.weight,
											sku_attrs: {
												[res.result.goodsAttr[0].attrName]: item.skuOne,
												[res.result.goodsAttr[1].attrName]: item.skuOne
											}
										})
									} else {
										this.skus.push({
											packagePrice: item.packagePrice,
											id: item.id,
											price: item.price,
											stock: item.stockNum,
											weight: item.weight,
											sku_attrs: {
												[res.result.goodsAttr[0].attrName]: item.skuOne
											}
										})
									}

								})
							} else {
								this.skus = []
							}
						}
					})
					setTimeout(() => {
						this.skuChange()
					}, 100)
				}
			}
		}
	}
</script>

<style lang="scss">
	.goods-scroll {
		height: 99vh;

		.u-wrap {
			// height: calc(100vh + 10px);
			/* #ifdef H5 */
			height: calc(100vh - var(--window-top));
			/* #endif */
			display: flex;
			flex-direction: column;

			.u-wrap-tabs {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.u-wrap-tabs-back {
					padding-right: 20px;
				}
			}
		}

		.u-search-box {
			padding: 18rpx 30rpx;
		}

		.u-menu-wrap {
			flex: 1;
			display: flex;
			overflow: hidden;
		}

		.u-search-inner {
			background-color: rgb(234, 234, 234);
			border-radius: 100rpx;
			display: flex;
			align-items: center;
			padding: 10rpx 16rpx;
		}

		.u-search-text {
			font-size: 26rpx;
			color: $u-tips-color;
			margin-left: 10rpx;
		}

		.u-tab-view {
			width: 176rpx;
			height: 100%;
		}

		.top-tabs {
			width: calc(100% - 176rpx);
			display: flex;
			justify-content: flex-end;
		}

		.u-tab-item {
			height: 90rpx;
			background: #f6f6f6;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 26rpx;
			color: #333333;
			font-weight: 400;
			line-height: 40rpx;

		}

		.u-tab-item-active {
			position: relative;
			color: #FE861C;
			font-size: 26rpx;
			font-weight: bold;
			line-height: 40rpx;
			background: #fff;
		}

		// .u-tab-item-active::before {
		// 	content: "";
		// 	position: absolute;
		// 	border-left: 4px solid $u-primary;
		// 	height: 32rpx;
		// 	left: 0;
		// 	top: 39rpx;
		// }

		.u-tab-view {
			width: 176rpx;
			height: 100%;
		}

		.right-box {
			background-color: rgb(250, 250, 250);

			.scorll {
				height: 21px;
			}
		}

		.page-view {
			padding: 16rpx;
			padding-top: 0;
		}

		.class-item {
			// margin-bottom: 30rpx;
			background-color: #fff;
			padding: 16rpx;
			padding-top: 0;
			border-radius: 8rpx;
		}

		.class-item:last-child {
			// min-height: 100vh;
		}

		.item-title {
			font-size: 26rpx;
			color: $u-main-color;
			font-weight: bold;
		}

		.item-menu-name {
			font-weight: normal;
			font-size: 24rpx;
			color: $u-main-color;
		}

		.item-container {
			// display: flex;
			// flex-wrap: wrap;
		}

		.thumb-box {
			width: 33.333333%;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			margin-top: 20rpx;
		}

		.item-menu-image {
			width: 120rpx;
			height: 120rpx;
		}
	}

	.minsbottom {
		border-bottom: 1px solid #f9f9f9;
	}

	.mins {
		display: flex;
		justify-content: space-between;
		overflow: hidden;

		.huangk {
			position: relative;
			left: -15rpx;
		}


	}

	.center {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.serch {
		display: flex;
		font-size: 28rpx;
		line-height: 90rpx;
		color: #959595;

		.serchcont {
			// height: 50rpx;
			background-color: #F0F0F0;
			display: flex;
			align-items: center;
			padding: 0rpx 32rpx;
			border-radius: 30rpx;
			justify-content: left;
		}
	}

	.boderred {
		width: 360rpx;
		border: 1px solid #FF2626;
		height: 36rpx;
		margin-top: 20rpx;
		font-size: 24rpx;
		color: #FF2626;

		.smalltext {
			background-color: #FF2626;
			line-height: 36rpx;
			color: #fff;
			padding: 0 5rpx;
		}

		.textsm {
			padding: 0 15rpx;
		}
	}

	.weixin {
		width: 64rpx;
		height: 64rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 50%;
		overflow: hidden;
	}

	.contentsdf {
		background-color: #fff;
		padding: 30rpx 20rpx;
		border-radius: 20rpx 20rpx 0rpx 0rpx;
		position: relative;
		// bottom: 66rpx;
		padding-bottom: 0;

		.contents-head {
			position: relative;

			.xintext {
				position: absolute;
				top: 90rpx;
				width: 150rpx;
				text-align: center;
				text-indent: 10rpx;
				font-size: 24rpx;
				right: -25rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #000000;
			}

			.shocng {
				position: absolute;
				right: 0;
				top: -80rpx;
				right: 20rpx;

				.xing {
					background-color: #fff;
					border-radius: 50%;
					padding: 22rpx;
				}
			}
		}

		.text-logo {
			margin-left: 20rpx;

			.name {
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #000000;
			}

			.time {
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #393939;
				margin-top: 10rpx;
			}
		}

		.logo {
			display: flex;

			.imgslogo {
				width: 110rpx;
				height: 110rpx;
				border-radius: 10rpx;
			}
		}

	}

	.bakcrgb {
		background: #262626;
		opacity: 0.3;
	}

	.head {
		width: 100%;
		// height: 300rpx;
		height: 240rpx;
		background-color: #fff;
		// background: url('@/static/homeimg/bgc.png') no-repeat;

		// background-size: 100% 100%;
		.head-cont {
			display: flex;
			// width: calc(100% - 245rpx);
			// padding-left: ;
			// padding-top: 100rpx;
			// padding-left: 40rpx;
			// padding-right: 205rpx;
			justify-content: space-between;
		}
	}

	.button {
		position: fixed;
		width: calc(100% - 40rpx);
		bottom: 40rpx;
		left: 20rpx;
		z-index: 555;
		height: 98rpx;
		background: #383838;
		border-radius: 49rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.smallbuton {
			margin-right: 20rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			background-color: #555555;
			padding: 16rpx 30rpx;
			text-align: center;
			border-radius: 36rpx;

		}

		.smallbuton2 {
			margin-right: 20rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			background-color: #FE861C;
			padding: 16rpx 30rpx;
			text-align: center;
			border-radius: 36rpx;

		}

		.btinone {
			padding-left: 40rpx;
		}

		.imghui {
			width: 88rpx;
			height: 66rpx;
		}

		.money {
			padding-left: 24rpx;
			font-size: 22rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #FFFFFF;

			.nummoney {
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
			}
		}
	}

	.goods {
		.goodsimg {
			width: 190rpx;
			height: 170rpx;
			border-radius: 15rpx;
		}

		.goodstext {
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #646464;
			padding-left: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.text-head {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #000000;
				word-break: break-all;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				/* 超出几行省略 */
				overflow: hidden;

			}

			.salesNum {
				display: flex;
				justify-content: space-between;
			}

			.mounys {
				display: flex;
				justify-content: space-between;
			}

			.nummoyneys {
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #FB2A2A;
			}

			.addcar {
				width: 44rpx;
				height: 44rpx;
				background-color: #FE861C;
				border-radius: 50%;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.addcars {
				width: 44rpx;
				height: 44rpx;
				background-color: #ccc;
				border-radius: 50%;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.addcarsa {
				background-color: #FE861C;
				padding: 6rpx 10rpx;
				font-size: 24rpx;
				color: #fff;
				border-radius: 8rpx;
			}

			.addcarsas {
				background-color: #cccccc;
				padding: 6rpx 10rpx;
				font-size: 24rpx;
				color: #fff;
				border-radius: 8rpx;
			}

			.jaddcar {
				width: 42rpx;
				height: 42rpx;
				background-color: #fff;
				border: 1px solid #FE861C;
				border-radius: 50%;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.numbershop {
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #000000;
				padding: 0 20rpx;
			}
		}
	}

	.shopdow {
		background: rgba(35, 35, 35, 0.6);
		border-radius: 3px;
		position: absolute;
		top: 0;
		width: 95px;
		height: 85px;
		color: #fff;
		font-size: 14px;
		text-align: center;
		line-height: 85px;
	}

	.shoko {
		background-color: rgba(253, 241, 231, 0.9);
		width: 50px;
		height: 20px;
		line-height: 20px;
		font-size: 14px;
		position: absolute;
		text-align: center;
		border-radius: 5rpx;
		color: #FE861C;
		top: 0;
	}

	.boxbachtactive {
		border: 1px solid #FE861C;
		border-radius: 10rpx;
		margin-top: 10rpx;
		color: #FE861C;
		margin-right: 40rpx;
		background-color: #fff4ea;

		.rightbodr {
			padding: 0rpx 14rpx;
			font-size: 24rpx;
			// white-space: nowrap;
			border-right: 1px solid #FE861C;
			display: flex;
			height: 56rpx;
			align-items: center;
		}

		.lingsd {
			// white-space: nowrap;
			font-size: 24rpx;
			padding: 0rpx 14rpx;
			display: flex;
			height: 56rpx;
			align-items: center;
		}
	}

	.boxbacht {
		border: 1px solid #F0F0F0;
		border-radius: 10rpx;
		margin-top: 10rpx;
		margin-right: 40rpx;

		.rightbodr {
			// white-space: nowrap;
			font-size: 24rpx;
			padding: 0rpx 14rpx;
			border-right: 1px solid #F0F0F0;
			display: flex;
			height: 56rpx;
			align-items: center;
		}

		.lingsd {
			// white-space: nowrap;
			font-size: 24rpx;
			padding: 0rpx 14rpx;
			display: flex;
			height: 56rpx;
			align-items: center;
		}
	}

	.tbas {
		height: 8rpx;
		position: absolute;
		bottom: -24rpx;
		left: 10rpx;
		background-color: #FE861C;
		border-radius: 4px 4px 0 0;
	}

	::v-deep .mescroll-empty {
		box-sizing: border-box;
		width: 100%;
		padding: 3.125rem 1.5625rem;
		text-align: center;
		position: relative;
		top: 150rpx;
	}
</style>
<style>
	::v-deep(.u-badge--error.data-v-06cca9b7) {
		background-color: #red;
	}
</style>